import { createStore, combineReducers } from 'redux'

const initialState = {
  title: "闲趣",
  token: null,
  user: {

  }
}

function reducer (state = initialState, action) {
  console.log("reducer:", state, action)
  switch (action.type) {
    case 'SET_TOKEN':
      // async to localhost disk
      return { ...state, token: action.token }
    case 'GET_TOKEN':
      return { ...state }
    case 'XX_DEMO':
      return Object.assign({}, state, {
        token: action.token
      })
    default:
      return state
  }
}

const store = createStore(combineReducers({
  app: reducer
}))

export default store

